<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
        }

        .artplayer-app {
            aspect-ratio: 16/9;
        }
    </style>
</head>
<body style="height: 2000px">
<div class="artplayer-app"></div>
<p style="height: 40px"></p>
<button onclick="setPip()">setPip</button>
<script src="https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.17/hls.min.js"></script>-->
<script>
    var container = document.querySelector('.artplayer-app');

    var art = new Artplayer({
        container: container,
        url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4',
    });

    let longPressTimer = null;
    const longPressDuration = 1000; // 长按的时间阈值，单位是毫秒

    art.events.proxy(container, 'touchstart', event => {
        // 启动计时器
        longPressTimer = setTimeout(() => {
            console.info('long press', event);
            // 在这里处理长按逻辑
            art.playbackRate = 2;
        }, longPressDuration);
    });

    art.events.proxy(container, 'touchend', event => {
        // 清除计时器
        clearTimeout(longPressTimer);
    });

    art.events.proxy(container, 'touchcancel', event => {
        // 如果触摸被取消（例如用户滑出元素），也清除计时器
        clearTimeout(longPressTimer);
    });

    art.events.hover(container, (event) => {
        console.info('mouseenter', event);
    }, (event) => {
        console.info('mouseleave', event);
    });
</script>
</body>
</html>
